package com.dhcc.DRGsHosp.web.controller;

import org.dayatang.utils.Page;
import org.openkoala.koala.commons.InvokeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhcc.DRGsHosp.facade.CostSubFacade;
import com.dhcc.DRGsHosp.facade.dto.CostSubDTO;

@Controller("drgsHospWebControllerchl20180314")
@RequestMapping("/CostSub")
public class CostSubController {
		
	@Autowired
	private CostSubFacade costSubFacade;
	
	@ResponseBody
	@RequestMapping("/add")
	public InvokeResult add(CostSubDTO costSubDTO) {
		costSubFacade.creatCostSub(costSubDTO) ;
		return InvokeResult.success();
	}
	
	@ResponseBody
	@RequestMapping("/pageJson")
	public Page pageJson(CostSubDTO costSubDTO, @RequestParam int page, @RequestParam int pagesize) {
		Page<CostSubDTO> all = costSubFacade.pageQueryCostSub(costSubDTO, page, pagesize);
		return all;
	}
	
	@ResponseBody
	@RequestMapping("/delete")
	public InvokeResult remove(@RequestParam String costSubCodes) {
		String[] value = costSubCodes.split(",");
        String[] idArrs = new String[value.length];
		for (int i = 0; i < value.length; i++) {
			idArrs[i] = value[i];
		}
        return costSubFacade.removeCostSubs(idArrs);
	}
	
		
    @ResponseBody
	@RequestMapping("/findAllCostSub")
    public InvokeResult findAllCostSub(){
    	return InvokeResult.success(costSubFacade.findAllCostSub());
    }
	
    
    @ResponseBody
   	@RequestMapping("/isCostSubCodeExist")
	public Boolean isCostSubCodeExist(String costSubcode){
    	return costSubFacade.isCostSubCodeExist(costSubcode);
	}
}
